<!doctype html>
<html>
<head>
    <title>大厨师</title>
    <meta charset="utf-8" />
    <meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type" />
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" name="viewport">
    <meta content="no-cache,must-revalidate" http-equiv="Cache-Control" />
    <meta content="no-cache" http-equiv="pragma" />
    <meta content="0" http-equiv="expires" />
    <meta content="telephone=no, address=no" name="format-detection" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <link type="text/css" rel="stylesheet" href="{RESNEW}css/style.css" />
    <link rel="stylesheet" type="text/css" href="{RES}css/wei_canyin.css" media="all" />
    <link rel="stylesheet" type="text/css" href="{RES}css/wei_dialog.css" media="all" />
    <script src="{RESNEW}js/jquery.js"></script>
    <script type="text/javascript" src="{RESNEW}js/TouchSlide.1.1.js"></script>
    <script type="text/javascript" src="{RES}js/wei_webapp_v2_common.js"></script>
    <script type="text/javascript">
    </script>
<body style='background-color: #000;'>
{template common_search}

    <section style="display: block; " class="productdetail">
        <div class="chefmainchair"><img  src="{$genius_list['thumb']}" height='175'/>
           
        </div>
        <div class="chefrightdiv">
            <div class="chefname">{$genius_list['title']}</div>
            <div class="cheftitle">适合人数:{$genius_list['rens']}<br />套餐价格:￥{$genius_list['totalprice']}元</div>
            <div class="chefdetail">
                <em>
                    {$genius_list['description']}
                </em>
                <i>更多</i>
            </div>
            <div class="goorder"><a href="javascript:void(0)" onclick="showImgDetail(this);event.stopPropagation();">选择时间档期 <img src="{RESNEW}images/go2.png"  height="25" /></a></div>
        </div>
    </section>

<section style="display: block; " class="mainnav">
 {$genius_list['content']}
</section>
<div id="ft">
    400-810-8888
</div>
{template wl_footer}
<script type="text/javascript">
    var goodid = '{$genius_list["id"]}';
    var price = '{$genius_list["marketprice"]}';
    window.selected = {
        total:{$totalnum},
        sdate:'{$sdate}',
        dishes: {if empty($idstr)}{}{else}{$idstr}{/if},
    };

    $(function(){
        $(".chefdetail").each(function(){
            var $targetEle = $(this).find("em").first();
            var $btnCtrl = $(this).find("i").last();
            var strAll = $targetEle.html();

            if (strAll.length >80)
            {
                var sonStr = strAll.substr(0,80);
                $targetEle.html(sonStr+"...");

                $btnCtrl.click(function(){

                    if ($btnCtrl.text()=="更多")
                    {
                        $targetEle.html(strAll);
                        $btnCtrl.text("隐藏");
                    }
                    else{
                        $targetEle.html(sonStr+"...");
                        $btnCtrl.text("更多");
                    }
                });
            }
            else{$btnCtrl.html("")}
        });
    });
    function showImgDetail(thi){
        MLoading.show('加载中');
        var params = {
        }        

        _doAjax("{php echo  $this->createMobileUrl('wlcheftimeajax',array('chefid'=>$genius_list['shop_id'])).'&chefid='.$genius_list['shop_id']; }", "POST", params, function(res) {
            MLoading.hide();

            if(res.type=="error"){
                alert(res.message);
            }else{

                var _tmpHtml = "<div class='content' style='background-color: white;padding-bottom: 10px'><h2>请选择厨师档期</h2>";
                _tmpHtml += "<center>";
                _tmpHtml += "<select name='sdate' id='sdate'>";
                _tmpHtml += "<option value='0'>请选择</option> ";
                for(sdate in res)
                {
                    _tmpHtml += "<option value='"+res[sdate]+"'>"+res[sdate]+"</option> ";
                }
                _tmpHtml += "</select><br/><span style='color: red;font-size: 10px'>(没有的日期说明厨师档期已满)</span>";

                _tmpHtml += "<div><button onclick='xuancai()'>开始下单</button></div>";
                _tmpHtml += "</center>";
                _tmpHtml += "</div>";
                MDialog.popupCustom(_tmpHtml,true,true);


            }

        });


    }

    function xuancai()
    {

        if($('#sdate').val() == 0)
        {
            alert('请选择服务日期');
            return false;
        }
        addToMenu();
        //window.location.href="{php echo  $this->createMobileUrl('wlindex',array('chefid'=>$genius_list['shop_id'])).'&chefid='.$genius_list['shop_id']; }&sdate="+$('#sdate').val();
    }

        function addToMenu(){
            var params = '[';
            //for(var key in window.selected.dishes){
                params += '{"dishes_id":{$genius_list["goodsid"]}'+ ",",
                params += '"price":500'+",",
                params += '"nums":1},'
           // }
            params = params.replace(/,$/, "");
            params += ']';

            $.ajax({
                'url':'{php echo  $this->createMobileUrl('wladdorder')}',
                'data':{'order':params,'sdate':$('#sdate').val(),'gtype':1,'shop_id':{php echo $genius_list['shop_id'];}},
                'type':'POST',
                'async':'false',
                'success':function(db){
                    location.href='{php echo  $this->createMobileUrl('wlcart')}';
                }
            });

        }


    $(document).ready(function(){
        $('#my_menu').click(function(){
            location.href='mobile.php?act=module&name=shopping3&do=wlcart&weid=1';

        });

    });



</script>
</body>
</html>
